/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pp.entites;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author arnaud
 */
@Entity
@Table(name = "mobiledevice_has_evenement")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MobiledeviceHasEvenement.findAll", query = "SELECT m FROM MobiledeviceHasEvenement m"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByIdmobileDevice", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.mobiledeviceHasEvenementPK.idmobileDevice = :idmobileDevice"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByIdCreateur", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.mobiledeviceHasEvenementPK.idCreateur = :idCreateur"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByNumEvenement", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.mobiledeviceHasEvenementPK.numEvenement = :numEvenement"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByTimestampReception", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.timestampReception = :timestampReception"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByTimestampDiffusion", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.timestampDiffusion = :timestampDiffusion"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByADiffuser", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.aDiffuser = :aDiffuser"),
    @NamedQuery(name = "MobiledeviceHasEvenement.findByIdmobileAndADiffuser", query = "SELECT m FROM MobiledeviceHasEvenement m WHERE m.mobiledeviceHasEvenementPK.idmobileDevice = :idmobileDevice AND m.aDiffuser = :aDiffuser")})
public class MobiledeviceHasEvenement implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MobiledeviceHasEvenementPK mobiledeviceHasEvenementPK;
    @Column(name = "timestamp_reception")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestampReception;
    @Column(name = "timestamp_diffusion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestampDiffusion;
    @Column(name = "a_diffuser")
    private Boolean aDiffuser;
    @JoinColumns({
        @JoinColumn(name = "idCreateur", referencedColumnName = "idCreateur", insertable = false, updatable = false),
        @JoinColumn(name = "num_evenement", referencedColumnName = "num_evenement", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Evenement evenement;
    @JoinColumn(name = "idmobileDevice", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Mobiledevice mobiledevice;

    public MobiledeviceHasEvenement() {
    }

    public MobiledeviceHasEvenement(MobiledeviceHasEvenementPK mobiledeviceHasEvenementPK) {
        this.mobiledeviceHasEvenementPK = mobiledeviceHasEvenementPK;
    }

    public MobiledeviceHasEvenement(String idmobileDevice, String idCreateur, int numEvenement) {
        this.mobiledeviceHasEvenementPK = new MobiledeviceHasEvenementPK(idmobileDevice, idCreateur, numEvenement);
    }

    public MobiledeviceHasEvenementPK getMobiledeviceHasEvenementPK() {
        return mobiledeviceHasEvenementPK;
    }

    public void setMobiledeviceHasEvenementPK(MobiledeviceHasEvenementPK mobiledeviceHasEvenementPK) {
        this.mobiledeviceHasEvenementPK = mobiledeviceHasEvenementPK;
    }

    public Date getTimestampReception() {
        return timestampReception;
    }

    public void setTimestampReception(Date timestampReception) {
        this.timestampReception = timestampReception;
    }

    public Date getTimestampDiffusion() {
        return timestampDiffusion;
    }

    public void setTimestampDiffusion(Date timestampDiffusion) {
        this.timestampDiffusion = timestampDiffusion;
    }

    public Boolean getADiffuser() {
        return aDiffuser;
    }

    public void setADiffuser(Boolean aDiffuser) {
        this.aDiffuser = aDiffuser;
    }

    public Evenement getEvenement() {
        return evenement;
    }

    public void setEvenement(Evenement evenement) {
        this.evenement = evenement;
    }

    public Mobiledevice getMobiledevice() {
        return mobiledevice;
    }

    public void setMobiledevice(Mobiledevice mobiledevice) {
        this.mobiledevice = mobiledevice;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mobiledeviceHasEvenementPK != null ? mobiledeviceHasEvenementPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MobiledeviceHasEvenement)) {
            return false;
        }
        MobiledeviceHasEvenement other = (MobiledeviceHasEvenement) object;
        if ((this.mobiledeviceHasEvenementPK == null && other.mobiledeviceHasEvenementPK != null) || (this.mobiledeviceHasEvenementPK != null && !this.mobiledeviceHasEvenementPK.equals(other.mobiledeviceHasEvenementPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.pp.entites.MobiledeviceHasEvenement[ mobiledeviceHasEvenementPK=" + mobiledeviceHasEvenementPK + " ]";
    }
    
}
